package com.qiuhui.spring_boot_02.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: Car
 * @Description: TODO
 * @author: tian
 * @date: 2021/3/30  3:55 下午
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Component  // 注册bean
/**
@ConfigurationProperties作用：
将配置文件中配置的每一个属性的值，映射到这个组件中；
告诉SpringBoot将本类中的所有属性和配置文件中相关的配置进行绑定
参数 prefix = “person” : 将配置文件中的person下面的所有属性一一对应
*/
@ConfigurationProperties(prefix = "car")
//@Validated
public class Car {
    @NotNull(message = "品牌不能为空")
    private String brand;
    @Max(value = 2000000,message = "价格不能超过200000")
    private Integer price;
    private List<String> series;
    private Date marketDate;
    private Map<String,Object> map;
    private MiniCar miniCar;
}
